package gui;

/* unimaner - University Manager - is a program to manage your time at university.

Copyright (C) 2009 Florian Wittmann

    This file is part of Unimaner.

    Unimaner is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Unimaner is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Unimaner.  If not, see <http://www.gnu.org/licenses/>.
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DialogWindow extends javax.swing.JFrame {
	
	JButton dialogOK;
	JLabel dialogLabel;

	public DialogWindow() {}

	public DialogWindow(String title, String text) {
		initComponents(title, text);
		setLocationRelativeTo(null);
		setVisible(true);
	}
	
	private void initComponents(String title, String text) {
		try {
			getContentPane().setLayout(new BorderLayout());
			this.setPreferredSize(new Dimension(300,200));
			this.setAlwaysOnTop(true);
			this.setResizable(false);
			this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle(title);

			dialogOK = new JButton();
			dialogOK.setText("OK");
			dialogOK.addMouseListener(new MouseAdapter() {
				@Override
				public void mouseClicked(MouseEvent evt) {
					dialogOKMouseClicked(evt);
				}
			});

			dialogLabel = new JLabel(text);

			this.add(dialogLabel, BorderLayout.CENTER);
			this.add(dialogOK, BorderLayout.SOUTH);
			pack();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	private void dialogOKMouseClicked(MouseEvent evt) {
		dispose();
	}

}
